<?php
use app\models\Mall;
use app\widgets\MallMBottomToolbarWidget;
use yii\helpers\Url;

$web = Url::base();
$institution_code = Mall::getCurrentInstitutionCode();
$integral_unit = \app\models\Mall::getCurrentInstitutionIntegralUnit();
$site_name = \app\models\Mall::getCurrentInstitutionSiteName();
$this->title = $site_name . '-微信扫码支付-(废弃)';
?>
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>微信扫码支付</title>
    <script src="<?= $web ?>/js/mall-m/jquery.js" type="text/javascript" charset="utf-8"></script>
    <script src="<?= $web ?>/js/tools.js"></script>
    <script type="application/javascript">
        $(function() {
            var width = $(document).width();
            if(width > 640) {
                width = 640;
            }
            var fontSize = (width / 320 * 20);
            $('html').css('font-size', fontSize);
        });
    </script>
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
            -webkit-tap-highlight-color: transparent;
        }

        a {
            text-decoration: none;
        }

        html {
            font-size: 20px !important;
        }

        .main {
            width: 12.5rem;
            margin-right: auto;
            margin-left: auto;
            font-family: "微软雅黑";
            font-size: .6rem;
        }



        .popup {
            width: 12.5rem ;
            padding-bottom: 1.75rem;
            background: #FFFFFF;
            border-radius: .25rem;
            z-index: 9;
            position: relative;
            overflow: hidden;
        }

        .popup .close-popup-btn {
            position: absolute;
            left: .3rem;
            top: .3rem;
        }

        .popup .close-popup-btn:active {
            background: #F6F6F6;
        }

        .popup .close-popup-btn img {
            width: 1.5rem;
            height: 1.5rem;
        }

        .popup .title {
            text-align: center;
            font-size: .55rem;
            color: #727171;
            margin-top: 1.75rem;
        }

        .popup .code {
            width: 9rem;
            height: 9rem;
            margin-left: 1.75rem;
            margin-top: 1rem;
            margin-bottom: 1.5rem;
        }

        .popup .pay-achieve-btn {
            width: 10.5rem;
            height: 1.75rem;
            margin-left: 1rem;
            text-align: center;
            line-height: 1.75rem;
            font-size: .65rem;
            color: #FFFFFF;
            border-radius: .25rem;
            background: #06be04;
            display: none;
        }

        .popup .pay-achieve-btn:active {
            background: #3ad838;
        }

    </style>
</head>

<body>
<script>
    var out_trade_no='';
    function create_wx_qr(){
        var data={};
        data.integral=<?=$integral?>;
        data.orderCode='<?=$orderCode?>';
        data.trade_type='NATIVE';

        var re=requestJsonMallM("<?=Url::to(['pay-integral/mall-m-weixin-pay-handle'])?>",data);
        if(re.status==0) {
            var code_url=re.data.code_url;
            out_trade_no=re.data.out_trade_no;
//            alert(out_trade_no+":"+code_url);
            $('.code').attr('src','qr-code-out?text='+encodeURI(code_url));
        }else {
            alert('error:'+re.message);
           // window.location.reload(true);
            return;
        }
    }
    $(function($){
        create_wx_qr();
    });
</script>
<div class="main">
    <div class="popup">
        <a class="close-popup-btn">
            <img src="<?= $web ?>/images/mall-m/close-popup-btn.png"/>
        </a>
        <p class="title">长按图片  识别二维码  支付</p>
        <img class="code" src=""/>
        <a href="" onclick="btn_ok()">
            <p class="pay-achieve-btn">我已完成支付</p>
        </a>
    </div>
</div>
<script type="text/javascript">
    btn_ok=function(){
        parent.window.location.href ="<?=Url::to(['mall-m/pay-order-success','institution_code'=>Mall::getCurrentInstitutionCode()])?>"+'&isMix=1&out_trade_no='+out_trade_no;
    };
    $(function(){

        $(".close-popup-btn").click(function() {
            $(parent.document).find('.shadeIframe,.pay_iframe').fadeOut();
        });
        $(".code").click(function() {
            $(".pay-achieve-btn").fadeIn();
        });

        $(".close-popup-btn,.shade").click(function() {
            $(parent.document).find('.shadeIframe,.pay_iframe').fadeOut();

        });
    })
</script>
</body>

</html>